<%-- 
    Document   : ChiTietSanPham
    Created on : Nov 3, 2012, 7:47:20 AM
    Author     : Suma
--%>
<%@page import="org.apache.jasper.tagplugins.jstl.core.ForEach"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.sun.org.apache.xerces.internal.impl.dv.util.HexBin"%>
<%@page import="java.nio.charset.Charset"%>
<%@page import="java.security.MessageDigest"%>
<%@page import="javax.swing.JOptionPane"%>
<%@page import="model.dao.*"%>
<%@page import="model.pojo.*"%>
<%@page import="javax.servlet.http.HttpSession"%>
<%
    String MaSanPham = "sp001";
    if (request.getParameter("MaSanPham") != null) {
        MaSanPham = request.getParameter("MaSanPham");
    }

    SanPham sp = (new SanPhamDAO()).get(MaSanPham);

    HangSanXuat hsx_sp = (new HangSanXuatDAO()).get(sp.getHangSanXuat().getMaHangSanXuat());
    //JOptionPane.showMessageDialog(null, hsx_sp.getTenHangSanXuat());
    ChiTietDanhMuc ctdm_sp = (new ChiTietDanhMucDAO()).get(sp.getChiTietDanhMuc().getMaChiTietDanhMuc());
    //JOptionPane.showMessageDialog(null, hsx_sp.getTenHangSanXuat() + ctdm_sp.getTenChiTietDanhMuc());
%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <script src="SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script> 
        <link href="SpryAssets/SpryTabbedPanels.css" rel="stylesheet" type="text/css" />
        <script src="SpryAssets/danhgiajs.js" type="text/javascript"></script>
    </head>
    <body>
        <!-- TemplateBeginEditable name="MainContent" -->

        <div style="z-index:auto; position:relative; border-style: solid; border-width: 1px;" id="tableformDangNhap">
            <div style="text-align: left; padding-top: 5px; margin-left:50px;" class="chitiet_tieude"><h1><%=sp.getTenSanPham()%></h1></div>
            <div style="margin-left:10px;">
                <table width="100%">
                    <tbody>
                        <tr valign="top">       
                            <td><table class="text2" border="0" cellpadding="0" cellspacing="0" width="620">
                                    <tr><td valign="top" width="255">
                                            <div style="margin-left:40px;">

                                                <img  src="<%=sp.getHinhAnh()%>" width="200" height="200" alt="<%=sp.getTenSanPham()%>" longdesc="<%=sp.getHinhAnh()%>" />

                                            </div>
                                        </td>
                                        <td align="left" valign="top">
                                            <div class="ThongTinSanPham_box" >
                                                <table class="fontTTSanpham" width="100%" border="0" cellspacing="0" cellpadding="0">
                                                    <tr>
                                                        <td width="150">Mã sản phẩm #: </td>
                                                        <td><%=sp.getMaSanPham()%></td>
                                                    </tr>
                                                    <tr>
                                                        <td>Hản sản xuất #:</td>
                                                        <td><a class="un" title="LG Electronics" href="http://www.tk."><%=hsx_sp.getTenHangSanXuat()%></a></td>
                                                    </tr>
                                                    <tr>
                                                        <td>Danh mục #:</td>
                                                        <td><a class="un" title="LG Electronics" href="http://www.tk."><%=ctdm_sp.getTenChiTietDanhMuc()%></a></td>
                                                    </tr>
                                                    <tr>
                                                        <td>Tình trạng : </td>
                                                        <td><%=(sp.getSoLuong() > 0 ? "Còn hàng" : "Hết hàng")%></td>
                                                    </tr>
                                                    <tr>
                                                        <td>Chất lượng : </td>
                                                        <td>Mới</td>
                                                    </tr>
                                                    <tr>
                                                        <td>Giá cả : </td>
                                                        <td><%=sp.getDonGia()%> $</td>
                                                    </tr>
                                                </table>              
                                            </div>    
                                            <script>
                                                                
                                                function tangGiamSoLuong(i, max){							  
                                                    var slt = document.getElementById("txtSoLuongDatHang");
                                                    var sl = parseInt(slt.value);
                                                    if(i == 1){if(sl>0){sl = sl - 1;}
                                                    }else{if(sl<max){sl =sl+1;}}
                                                    slt.value = sl;	
                                  
                                                }
                                            </script> 
                                            <form method="post" action="index.jsp">   
                                                <input hidden="" name="MainContent"  type="text" value="GioHang" />
                                                <div style="padding-top: 15px; padding-bottom:15px;">    
                                                    <button type="button" onclick="tangGiamSoLuong(1,<%=sp.getSoLuong()%>)">-</button>
                                                    <input name="SoLuong" id="txtSoLuongDatHang" type="number" value="1" style="width: 40px;"/>
                                                    <button type="button" onclick="tangGiamSoLuong(0,<%=sp.getSoLuong()%>)">+</button>
                                                    <input hidden name="MaSanPham" id="txtSoLuongDatHang2" type="number" value="<%=MaSanPham%>" size="5"/>
                                                    <input name="Action" type="number" value="DatMua" hidden />
                                                </div>
                                                <div id="AddToCartDiv" style="padding-top: 5px; padding-bottom:15px;">

                                                    <input  type="submit" value="" style="background-image:url(images/AddToCart_new.jpg); cursor: pointer;; background-repeat:no-repeat; width:150px; height:30px;" />
                                                </div>      
                                            </form>

                                        </td>
                                    </tr>            
                                </table>            
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <div class="chitiet_body">

                <div id="TabbedPanels1" class="TabbedPanels">
                    <ul class="TabbedPanelsTabGroup">
                        <li class="TabbedPanelsTab" tabindex="0">Thông tin sản phẩm</li>
                        <li class="TabbedPanelsTab" tabindex="0">Đánh giá</li>
                    </ul>
                    <div class="TabbedPanelsContentGroup">
                        <div class="TabbedPanelsContent">
                            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                    <td class="font_tieude">GIỚI THIỆU THÔNG TIN CƠ BẢN</td>
                                </tr>
                                <tr>
                                    <td>
                                        <%= sp.getMoTa()%>
                                    </td>
                                </tr>
                            </table>

                        </div>
                        <div class="TabbedPanelsContent">



                            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                    <th width="15%" rowspan="2" scope="row">Đánh giá:</th>
                                    <td width="85%">

                                        <select name="ctl00$cphMain$ctl00$ctl03$ctl00$ddlRating_Review" id="ctl00_cphMain_ctl00_ctl03_ctl00_ddlRating_Review" class="NormalTextBox" onchange="javascript:OnChangeRate();" style="width:256px;">
                                            <option value="5">5 sao (Tốt nhất)</option>
                                            <option value="4">4 sao</option>
                                            <option value="3">3 sao (Trung bình)</option>
                                            <option value="2">2 sao</option>
                                            <option value="1">1 sao (Tồi nhất)</option>
                                        </select>
                                        <% int idanhgia = sp.getDiemDanhGia();%>         
                                    </td>
                                </tr>
                                <tr>
                                    <td style="padding:5px">
                                        <%
                                            for (int p = 1; p <= sp.getDiemDanhGia(); p++) {
                                        %>
                                        <div id="star-<%=p%>" class="rating-on" onmouseover="javascript:OverStarRating(<%=p%>, <%=idanhgia%>);"></div>
                                        <%}%>
                                        <%
                                            for (int p = sp.getDiemDanhGia() + 1; p <= 5; p++) {
                                        %>

                                        <div id="star-<%=p%>" class="rating-off" onmouseover="javascript:OverStarRating(<%=p%>, <%=idanhgia%>);"></div>
                                        <%}%>

                                        <div class="Clear"></div></td>
                                </tr>
                                <tr>
                                    <th scope="row">Tiêu đề:</th>
                                    <td>
                                        <input style="width:500px;" type="text" name="txtTieuDe" id="txtTieuDe" /></td>
                                </tr>
                                <tr>
                                    <th scope="row">Nội dung:</th>
                                    <td><textarea style="width:500px; height:150px;" name="txtareaNoiDung" id="txtareaNoiDung" cols="" rows=""></textarea></td>
                                </tr>
                                <tr>
                                    <th scope="row">Họ Tên:</th>
                                    <td><input style="width:500px;" type="text" name="txtHoTen" id="txtHoTen" /></td>
                                </tr>
                                <tr>
                                    <th scope="row">&nbsp;</th>
                                    <td>                                 <input id="btnSubmit_Review" value="Gửi bình luận của bạn" 
                                                                                onclick="javascript:CheckDataInput();" type="button" /></td>
                                </tr>
                                <script>
                                    function CheckDataInput(){                                                           
                                        var txtt = document.getElementById('txtHoTen');
                                        if(txtt.value.trim() == 0){
                                            alert("Vui lòng nhập đầy đủ thông tin: Họ Tên");
                                            txtt.focus();
                                            return;
                                        }      
                                        var txtnd =document.getElementById('txtareaNoiDung');
                                        if(txtnd.value.trim() == 0){
                                            alert("Vui lòng nhập đầy đủ thông tin: Nội dung");
                                            txtnd.focus();
                                            return;
                                        }  
                                        var txttd= document.getElementById('txtTieuDe');
                                        if(txttd.value.trim() == 0){
                                            alert("Vui lòng nhập đầy đủ thông tin: Tiêu đề");
                                            txttd.focus();
                                            return;
                                        }
                                    }
                                                        
                                </script>
                            </table>


                        </div>
                    </div>
                </div>

            </div>
        </div>
        <script type="text/javascript">
            var TabbedPanels1 = new Spry.Widget.TabbedPanels("TabbedPanels1");
        </script>

        <!-- TemplateEndEditable -->
    </body>
</html>
